public class demo11 {
    public static void main(String[] args) {
        int a=8;
        int b=12;
        int c=1;
        for(int d=1;d<=8;d++){
            if ((b % d ==0) && (a % d==0)){
                System.out.println(d);
                c=d;
            }
        }
        System.out.println(c);
    }
}
